class Friend:
    def __init__(self):
        self.friend_li =[]
    def welcome(self):
        print("**欢迎使用好友管理系统**")
        print("1:添加好友")
        print("2:删除好友")
        print("3:备注好友")
        print("4:展示好友")
        print("5:好友分组")
        print("6:退出")
        while True:
            option=input("请选择功能\n")
        #添加好友
            if option == '1':
                self.add_friend()
        #删除好友
            elif option == '2':
                self.del_friend()
        #备注好友
            elif option == '3':
                self.modify_friend()
        #展示好友
            elif option == '4':
                self.show_friend()
        #分组好友
            elif option == '5':
                self.group_friend()
            elif option == '6':
                break
        def add_friend(self):
            add_friend = input("请输入要添加的好友：")
            self.friend_li.append(add_friend)
            print('添加成功')
        def get_all_friends(self):
            new_li =[]
            for friend_li_elem in self.friend_li:
                #判断元素类型
                if type(friend_li_elem) == dict:
                #遍历字典
                    [new_li.append(dict_elem_name) for
                    dict_elem in friend_li_elem.values()
                    for dict_elem_name in dict_elem]
                else:
                    new_li.append(friend_li_elem)
                    return new_li
        def get_all_groups(self):
            groups = []
            for friend_li_elem in self.friend_li:
                if type(friend_li_elem) == dict:
                    groups.append(friend_li_elem)
                return groups
        def get_all_groups_name(self):
            groups_name =[]
            for dict_elem in self.get_all_groups():
                for j in dict_elem:
                    groups_name.append(j)
                return groups_name
        def del_friend(self):
                if len(self.friend_li) !=0:
                    del_name = input("请输入删除好友的姓名：")
                    #删除好友未分组
                    if del_name in self.friend_li:
                        self.friend_li.remove(del_name)
                        print('删除成功')
                    else:
                        #删除好友在分组内
                        if del_name in self.get_all_friends():
                            if del_name in self.get_al1_friends():
                                for group_data in self.get_al1_groups():
                                    for group_friend_li in
                                     group_data.values():
                                    if del_name in group_friend_li:
                                     group_friend_li.remove(del_name)
                                    continue
                                print('删除成功')
                            else:
                                        print('列表为空')
